package com.task.myapplication11;

import androidx.appcompat.app.AppCompatActivity;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.webkit.JavascriptInterface;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.EditText;

public class myWebView extends AppCompatActivity {

    @SuppressLint({"SetJavaScriptEnabled", "JavascriptInterface"})
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_web_view);
        WebView v1=findViewById(R.id.my);
        WebView v2=findViewById(R.id.school);
        v1.loadUrl("file:///android_asset/index.html");
        v1.getSettings().setJavaScriptEnabled(true);
        v1.addJavascriptInterface(this,"myfunction");
        v2.loadUrl("https://www.cup.edu.cn/");
        v1.setWebChromeClient(new WebChromeClient());
        v2.setWebViewClient(new WebViewClient());
    }
    @JavascriptInterface
    public String call()
    {
        EditText e=findViewById(R.id.message);
        return e.getText().toString();
    }
}